# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.65])
AC_INIT([SHACrypt], [1.2.3], [shacrypt@googlegroups.com], [shacrypt], [http://shacrypt.googlecode.com/])
AC_SUBST([COMMAVERSION], ['1,2,3,0'])
AC_COPYRIGHT([SHACrypt is licensed under the GPL, version 3 or higher.])
AC_CONFIG_SRCDIR([src/commandline.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([dist-bzip2 subdir-objects gnits -Wall])

# Checks for programs.
AC_PROG_CC
AC_PROG_RANLIB
AM_PROG_CC_C_O
AC_PROG_SED
AC_CHECK_TOOL([WINDRES_EXE], [windres], [windres])

# Check file extensions
AC_EXEEXT
AC_OBJEXT

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T

# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset])

# Options
AC_ARG_ENABLE([gui], [AS_HELP_STRING([--enable-gui],
	[build the GTK-based graphical user interface])],
	[], [enable_gui=no])
AC_ARG_ENABLE([commandline], [AS_HELP_STRING([--disable-commandline],
	[don't build the command line program])],
	[], [enable_commandline=yes])
AC_ARG_WITH([windows], [AS_HELP_STRING([--with-windows],
	[use this if your build target is Windows @<:@default=check@:>@])],
	[], [with_windows=check])

# Check options
GUI_CFLAGS=
GUI_LIBS=
AS_IF([test "$enable_gui" != "no"],
	[PKG_CHECK_MODULES([GUI], [gtk+-2.0 gmodule-2.0 gthread-2.0])],
	[])
AM_CONDITIONAL([WANT_GUI], [test "$enable_gui" != "no"])
AC_SUBST([GUI_CFLAGS])
AC_SUBST([GUI_LIBS])
COMMANDLINE=
AS_IF([test "$enable_commandline" == "yes"],
	[COMMANDLINE=shacrypt],
	[])
AC_SUBST([COMMANDLINE])
AS_IF([test "$with_windows" == "check"],
	[AC_CANONICAL_HOST
	AS_IF([test "$host_os" == "mingw32"],
		[with_windows=yes], [with_windows=no])],
	[])
DWINDOWS=
MWINDOWS=
AS_IF([test "$with_windows" == "yes"],
	[DWINDOWS=-DWINDOWS
	MWINDOWS=-mwindows])
AC_SUBST([DWINDOWS])
AC_SUBST([MWINDOWS])
AM_CONDITIONAL([WITH_WINDOWS], [test "$with_windows" == "yes"])

# Create the Makefiles
AC_CONFIG_FILES([
	Makefile
	src/Makefile
	tests/Makefile
	docs/Makefile
])
AC_OUTPUT
